package com.data.core.controller;

import com.common.pojo.Result;
import com.common.vo.MessageLogVo;
import com.data.core.service.MessageLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(value = "发送消息相关API")
@RestController
@RequestMapping("message")
public class MessageLogController {

    @Resource
    private MessageLogService messageLogService;

    @ApiOperation(value = "保存发送消息",notes = "保存消息")
    @PostMapping(value = "save")
    public Result<?> save(@RequestBody MessageLogVo messageLogVo) throws Exception {
        Result result = new Result();
        result.OK(messageLogService.save(messageLogVo));
        return result;
    }

    @ApiOperation(value = "更新发送消息",notes = "更新")
    @PostMapping("update")
    public Result<?> update(@RequestBody MessageLogVo messageLogVo) throws Exception {
        Result result = new Result();
        result.OK(messageLogService.update(messageLogVo));
        return result;
    }

    @ApiOperation(value = "查询发送失败的消息",notes = "查询发送失败的消息")
    @PostMapping("find")
    public Result<?> findFailureMes(@RequestBody MessageLogVo messageLogVo) throws Exception {
        Result result = new Result();
        result.OK(messageLogService.findFailureMes(messageLogVo));
        return result;
    }
}
